;(function () {
	new Vue({
		el: '#invoicingLimit',
		data: {
			invoicingLimit:false,
      invoicingInputData:'',
      invoicingLimitData:[],
		},
		methods: {
			invoicingOpen () {
				var that = this
        this.invoicingLimit = !this.invoicingLimit
        hlhttp.get({
          url: 'project/voucher_limits',
          success: function (res) {
            that.invoicingLimitData = res
            that.invoicingLimitData.map(item=>{
              if(!item.voucherLimit.includes(',')){
                item.voucherLimit = item.voucherLimit.replace(/\B(?=(\d{3})+(?!\d))/g,'$&,')
                return item
              }
            })
          }
        })
			},
			showInput(index,val,id){
        var that = this
        if(val=='edit'){
          this.$set(this.invoicingLimitData[index],'flag',true)
        }else if(val=="sure"){
          let newV = (this.invoicingInputData*1).toFixed(2);
          hlhttp.put({
            url: 'project/voucher_limit',
            data:{
              id,
              voucher_limit:newV
            },
            success: function (res) {
              hl.toast('操作成功')
              that.invoicingOpen()
              that.invoicingLimit= true
              that.invoicingInputData=''
            }
          })
          
        }else{
          this.$set(this.invoicingLimitData[index],'flag',false)
          this.invoicingInputData=''
        }
      },
		},
		mounted () {
			this.invoicingOpen()
		}
	})
} ())
